Skip to content

Conversation

@muodov
Copy link
Member

@muodov muodov commented Mar 7, 2025

A minor tweak to make the test output more helpful


Note

Send autoconsentError messages on rule failures and detect/popup errors; enable CI to log these and pass detailed log config; update tests to stub messaging.

  • Core/runtime:
    • Report autoconsentError when a rule step fails in _runRulesSequentially (lib/cmps/base.ts).
  • Detection flow:
    • On exceptions in detectCmp and detectPopup/waitForPopup, send autoconsentError with CMP name and error message (lib/web.ts).
  • Playwright runner:
    • In CI, log only autoconsentError messages; pass explicit logs config in initResp (playwright/runner.ts).
  • Tests:
    • Stub sendContentMessage in mocks to accommodate new error reporting (tests-wtr/rules/logical-rules.test.ts).

Written by Cursor Bugbot for commit ab47a3a. This will update automatically on new commits. Configure here.

@muodov muodov added the tests Add or improve existing tests label Mar 7, 2025
@muodov muodov requested review from noisysocks and sammacbeth March 7, 2025 16:58
Copy link
Contributor

@noisysocks noisysocks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I made very similar changes to playwright/runner.ts locally when I was debugging issues.

Code looks good to me aside from question around whether it’s a good idea to have AutoConsent leak information about the messaging channel.

Could you please provide testing instructions?

domActions: DomActions;
filtersEngine: FiltersEngine;
protected sendContentMessage: MessageSender;
sendContentMessage: MessageSender;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe _runRulesSequentially in AutoConsentCMP should throw an error that AutoConsent catches? We're mixing concerns somewhat by having AutoConsentCMP know about the messaging channel.

Copy link
Contributor

@noisysocks noisysocks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous review.

msg: 'Rule step failed',
details: `${JSON.stringify(rule)}`,
},
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Failed detection rules incorrectly reported as errors

The _runRulesSequentially method now sends an autoconsentError message whenever a non-optional rule step returns false. This is problematic because this method is called by detectCmp() and detectPopup() during CMP detection. When checking if a CMP is present, most CMPs' detection rules are expected to fail (since typically only one CMP is on a page). The new code treats these normal detection failures as errors, flooding the message channel with false "errors" for every CMP that isn't present and every failed detection step. This makes test output less helpful, not more, as real errors become buried in noise.


Please tell me if this was useful or not with a 👍 or 👎.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Add or improve existing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants